package com.twu.biblioteca;


public class Movie {

    private String title;
    private int year;
    private String director;
    private int rating;

    public Movie(String name, Integer year, String director, Integer rating) {
        this.title = name;
        if (year < 1800)
            throw new IllegalArgumentException("Year must be >= 1800");
        if (year > 3000)
            throw new IllegalArgumentException("Year must be <= 3000");
        this.year = year;
        this.director = director;
        if (rating != null && rating < 1)
            throw new IllegalArgumentException("Rating must be >= 1");
        if (rating != null && rating > 10)
            throw new IllegalArgumentException("Rating must be <= 10");
        this.rating = rating;
    }

    public String getTitle() {
        return title;
    }

    public int getYear() {
        return year;
    }

    public String getDirector() {
        return director;
    }

    public int getRating() {
        return rating;
    }

    public String toString() {
        return title + " (" + year + "), " + director + " (" + rating + "/10)";
    }
}
